package com.example.management.mapper;

import com.example.management.pojo.Dormitory;
import com.example.management.pojo.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DormitoryMapper {
    @Select("select * from dormitory")
    List<Dormitory> getAllDormitory();

    //    通过楼号和宿舍号查到宿舍编码
    Integer selectByAllTag(Dormitory dormitory);

    List<Student> selectByDormitoryNumber(Dormitory dormitory);

    @Delete("delete from dormitory where number=#{number}")
    void deleteByNumber(Dormitory dormitory);

    void insertDormitory(Dormitory dormitory);

    //    根据宿舍编号计算出该宿舍的人数
    @Select("select count(*) from student where dormitory_number=#{number}")
    Integer selectByNumber(Dormitory dormitory);

    //动态修改速宿舍的信息（除了宿舍编号）
    void changeDormitory(Dormitory dormitory);

    @Select("select * from dormitory where number=#{number}")
    Dormitory selectDormitory(Dormitory dormitory);


}
